package com.ruoyi.syrw.common;

import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor
public class QuadFunction {

    private double a;
    private double b;
    private double c;

    public double value(double x, double... parameters) {
        double a = parameters[0];
        double b = parameters[1];
        double c = parameters[2];
        return (a * Math.pow(x, 2) + b * x + c);
    }

    public double getY(double x) {
        return value(x, a, b, c);
    }

    public QuadFunction(double a, double b, double c) {
        this.a = Double.isNaN(a) ? 0 : a;
        this.b = Double.isNaN(b) ? 0 : b;
        this.c = Double.isNaN(c) ? 0 : c;
    }
}
